<?php

/**
 * 供应链模块
 */
namespace app\schain\controller;

use app\businesscard\model\BusinessCategoryModel;
use app\schain\service\EnterpriseService;
use cmf\controller\HomeBaseController;

class IndexController extends HomeBaseController {

	public function index() {

		$param = $this->request->param();

		$categoryId = $this->request->param('category', 0, 'intval');

		//只查询已审核发布的企业
		$param['is_published'] = 1;

		$enterpriseService = new EnterpriseService();
		$data = $enterpriseService->adminEnterpriseList($param);

		$data->appends($param);

		$schainCategoryModel = new BusinessCategoryModel();
		$categoryTree = $schainCategoryModel->adminCategoryTree($categoryId);

		$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
		$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
		$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
		$this->assign('ents', $data->items());
		$this->assign('category_tree', $categoryTree);
		$this->assign('category', $categoryId);
		$this->assign('page', $data->render());
		$this->assign('total', $data->total());

		return $this->fetch(':index');
	}

}
